package cn.edu.sasu.controller;

import cn.edu.sasu.common.base.LayuiRespResult;
import cn.edu.sasu.common.base.RespResult;
import cn.edu.sasu.common.constants.Constant;
import cn.edu.sasu.domain.dto.PatientEducationActivityDTO;
import cn.edu.sasu.domain.entity.PatientEducationActivity;
import cn.edu.sasu.service.PatientEducationActivityService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author pushuqi
 */
@RestController
@RequestMapping("/patient_education_activity")
public class PatientEducationActivityController {
    @Resource
    private PatientEducationActivityService activityService;
    @GetMapping("/findActivityAll")
    public LayuiRespResult findActivityAll(Integer page,Integer limit){
        return activityService.activityList(page,limit);
    }
    @GetMapping("/findActivities")
    public RespResult Activities(){
        List<PatientEducationActivity> deptList=activityService.getActivities(Constant.DELETE_FLAG_YES);
        return RespResult.success(deptList);
    }
    @PostMapping("/del")
    public RespResult del(Integer activityId){
        return activityService.delActivityById(activityId);
    }

    // 批量删除
    @PostMapping("/batchdel")
    public RespResult batchdel(Integer[] ids){
        return activityService.batchdel(ids);
    }

    // 搜索
    @GetMapping("/search")
    public LayuiRespResult search(Integer page,Integer limit,String activityName,Byte activityStatus){
        return activityService.search(page,limit,activityName,activityStatus);
    }

    // 保存
    @PostMapping("/save")
    public RespResult save(@RequestBody @Validated PatientEducationActivity activity){
        return activityService.save(activity);
    }
    // 更新
    @PostMapping("/update")
    public RespResult update(@RequestBody @Validated PatientEducationActivityDTO activityDTO){
        return activityService.update(activityDTO);
    }
}

